package cn.edu.hqu.example.bj.experiment_3;

import android.content.Context;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import butterknife.ButterKnife;
import butterknife.OnClick;


//没有implements 声明接口会出错在 第一个接口this问题
public class MainActivity extends AppCompatActivity implements Button.OnClickListener {

    private TextView text;

    private Button button1;
    private Button button2;
    private Button button3;
    private Button button4;
    private Button button5;
    private Button button6;
    private Button button7;
    private Button button8;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.setContentView(R.layout.activity_main);

        button1 = (Button)findViewById(R.id.button1);
        button2 = (Button)findViewById(R.id.button2);
        button3 = (Button)findViewById(R.id.button3);
        button4 = (Button)findViewById(R.id.button4);
        button5 = (Button)findViewById(R.id.button5);
        button6 = (Button)findViewById(R.id.button6);
        button7 = (Button)findViewById(R.id.button7);
        button8 = (Button)findViewById(R.id.button8);

        text = (TextView)findViewById(R.id.text);

        button1.setOnClickListener(this);

        button2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                text.setText("点击了采用匿名内部类作为监听器");
            }
        });



        button4.setOnClickListener(new MyOnClicklistenter() );

        button5.setOnClickListener(new Clicklistenter() {
            public void onClick(View v)
            {
                text.setText("点击了采用外部类作为监听器");
            }
        });

        ButterKnife.bind(this);

        button7.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(MainActivity.this,ConfigurationTest.class);
                startActivity(intent);
            }
        });

        button8.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(MainActivity.this,ProgressDialogTest.class);
                startActivity(intent);
            }
        });


    }
    
    @Override
    public void onClick(View view)
    {
        switch (view.getId())
        {
            case R.id.button1:
                //Toast.makeText(context, "点击了采用Activity作为监听器", Toast.LENGTH_SHORT).show();
                text.setText("点击了采用Activity作为监听器");
                break;
        }
    }

    public void clickHandler(View vie)
    {
        text.setText("点击了采用绑定标签作为监听器");
    }

    public class MyOnClicklistenter implements View.OnClickListener {
        public void onClick(View v)
        {
            text.setText("点击了采用内部类作为监听器");
        }
    }

    @OnClick(R.id.button6 )   //给 button1 设置一个点击事件
    public void show(){
        text.setText("点击了采用ButterKnife绑定作为监听器");
    }


}


class Clicklistenter implements View.OnClickListener{

    @Override
    public void onClick(View v)
    {

    }
}

